package org.ds.biz.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table (name="entity_transaction")
@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn (name="transaction_type", discriminatorType=DiscriminatorType.STRING)
public abstract class AccountTransaction
{
	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	@Column (name = "transaction_id")
	private Long id = null;
	
	@Column (name = "transaction_type", insertable = false, updatable = false)
	private String txType = null;
	
	@Column (name = "transaction_date")
	private Date txDate = null;
	
	@Column (name = "transaction_desc")
	private String txDescription = null;
	
	@Column (name = "transaction_fee")
	private Double txFee = null;
	
	@ManyToOne
	@JoinColumn (name = "customer_id", updatable = false, insertable = false)
	private Customer customer;
	
	public AccountTransaction(String type)
	{
		txType = type;
		txDate = new Date();
	}

	public String getType()
	{
		return txType;
	}

	public void setType(String type)
	{
		txType = type;
	}

	public Date getDate()
	{
		return txDate;
	}

	public void setDate(Date date)
	{
		txDate = date;
	}

	public void setDescription(String description)
	{
		txDescription = description;
	}

	public String getDescription()
	{
		return txDescription;
	}

	public void setFee(Double fee)
	{
		txFee = fee;
	}

	public Double getFee()
	{
		return txFee;
	}
	
	public Customer getCustomer()
	{
		return customer;
	}

	public void setCustomer(Customer customer)
	{
		this.customer = customer;
	}
	
	protected void setTransactionID(Long id)
	{
		this.id = id;
	}
	
	protected Long getTransactionID()
	{
		return id;
	}
}
